package com.leoman.dao;

import com.leoman.entity.Mind;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * MindDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:44.
 */
public interface MindDao extends JpaRepository<Mind, Integer>, JpaSpecificationExecutor<Mind> {

    @Query("select a from Mind a where a.user.id = ?1 and a.isDraft = 1")
    Mind iFindDraftByUserId(Integer userId);

    @Query("select a from Mind a where a.isDraft = 0 and a.isTop = 1")
    Mind iFindOneWithTop();

    @Query("select a from Mind a where a.isAdmin = 1")
    Mind iFindOneWithAdmin();
}